<?php
namespace Buickwang\Calculator;
use Buickwang\Calculator\Interfaces\CalculatorInterface;
use Buickwang\Calculator\Models\CalculatorModel;

class Factory
{
    public static function build(CalculatorModel $model): CalculatorInterface
    {
        $classname = $model->calcultor_name;
        $namespace = 'Buickwang\\Calculator\\Calculators\\';
        $fullclass = $namespace.$classname;
        if (!class_exists($fullclass)) {
            throw new \Exception('不存在的计算器类');
        }
        return new $fullclass;
    }
}